package calao.contact.client;

import java.util.Comparator;

import com.google.gwt.user.client.rpc.IsSerializable;

public class Contact 
implements IsSerializable, Comparable
{

	int id;

	int[] groups = {};
	
	String name;
	String phone;
	String fax;
	String email;

	PostAddress address;
	
	String notes;
		
	public Contact() {}
	
	public Contact(int id)
	{
		this.id = id;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public int compareTo(Object obj) {
		Contact info = (Contact)obj;
		if (name==null) return info.name==null? 0 : -1;
		if (info.name==null) return 1;
		return name.compareTo(info.name);
	}

	public int[] getGroups() {
		return groups;
	}

	public void setGroups(int[] groups) 
	{
		this.groups = groups;
	}

	public PostAddress getAddress() 
	{
		return address;
	}

	public void setAddress(PostAddress address) 
	{
		this.address = address;
	}

	public String getNotes() 
	{
		return notes;
	}

	public void setNotes(String notes) 
	{
		this.notes = notes;
	}
	
	public static Comparator getComparator()
	{
		return new Comparator() {
			public int compare(Object o1, Object o2) {
				return ((Contact)o1).compareTo((Contact)o2);
			}
		};
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id) 
	{
		this.id = id;
	}
	
	public String getLabel()
	{
		return name;
	}

}
